package com.sqx.modules.errand.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.errand.service.TbIndentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/tbindent")
@Api(value = "管理端-跑腿订单", tags = {"管理端-跑腿订单"})
public class TbIndentController {

    @Autowired
    private TbIndentService tbIndentService;

    @ApiOperation("查看所有派单任务")
    @GetMapping(value = "findallIndent")
    public Result findallIndent(Integer page, Integer limit, Long userId, Long riderUserId, Long shopId,Integer indentType,Integer ordersNo,Integer status,String riderPhone){

        return tbIndentService.findallIndent(page, limit, userId, riderUserId, shopId,indentType,ordersNo,status,riderPhone);
    }

    @ApiOperation("任务中心 查看所有订单")
    @PostMapping(value = "findAllIndent")
    public Result findAllIndent(String indentType, String phone, String indentState, Integer page, Integer limit, String date, String dateType,String riderPhone){

        return tbIndentService.findAllIndent(indentType, phone, indentState, page, limit, date, dateType,riderPhone);
    }

    @ApiOperation("任务中心 查看所有订单")
    @PostMapping(value = "findAllIndents")
    public Result findAllIndents(String indentType, String phone, String indentState, Integer page, Integer limit, String date, String dateType,String riderPhone){

        return tbIndentService.findAllIndents(indentType, phone, indentState, page, limit, date, dateType,riderPhone);
    }

    @ApiOperation("订单中心")
    @PostMapping(value = "IndentCenter")
    public Result IndentCenter(Integer page, Integer limit, String indentType, String indentNumber, String indentState, String phone, String date, String dateType){

        return tbIndentService.IndentCenter(page, limit, indentType, indentNumber, indentState, phone, date, dateType);
    }

    @ApiOperation("管理端修改订单状态")
    @PostMapping(value = "updateIndentState")
    public Result updateIndentState(String indentNumber, String indentState){

        return tbIndentService.updateIndentState(indentNumber, indentState);
    }

    @ApiOperation("管理员下架订单")
    @PostMapping(value = "adminSoldOutIndent")
    public Result adminSoldOutIndent(String indentNumber){

        return tbIndentService.adminSoldOutIndent(indentNumber);
    }


    @PostMapping(value = "riderCancleIndent")
    @ApiOperation("骑手取消订单")
    public Result riderCancleIndent(String indentNumber){
        return tbIndentService.riderCancleIndent(indentNumber,2);
    }

    @ApiOperation("数据中心")
    @GetMapping(value = "findDataCenter")
    public Result findDataCenter(){

        return tbIndentService.findDataCenter();
    }

    @ApiOperation("任务分析")
    @GetMapping(value = "taskAnalysis")
    public Result taskAnalysis(String dateType, String date, Integer page, Integer limit, String indentState){

        return tbIndentService.taskAnalysis(dateType, date, page, limit, indentState);
    }

    @ApiOperation("订单分析")
    @GetMapping(value = "selectOrderByStatus")
    public Result selectOrderByStatus(String date, String dateType){

        return tbIndentService.selectOrderByStatus(date, dateType);
    }

    @ApiOperation("骑手收入统计 完成订单数统计")
    @GetMapping(value = "findIncome")
    public Result findIncome(Long userId, String date, String dateType, Integer page, Integer limit){

        return tbIndentService.findIncome(userId, date, dateType, page, limit);
    }

}
